<html>

<head>
    <title>grapecity_spreadJS_demo</title>
    <script src="jquery_3.1.1.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="gc.spread.sheets.excel2013white.14.2.2.css" type="text/css">
    <script src="gc.spread.sheets.all.14.2.2.min.js" type="text/javascript"></script>
    <script src="gc.spread.excelio.14.2.2.min.js" type="text/javascript"></script>
    <script src="https://cdn.grapecity.com.cn/spreadjs/scripts/FileSaver.min.js" type="text/javascript"></script>
    <script src="gc.spread.sheets.resources.zh.14.2.2.min.js" type="text/javascript"></script>
    <script src="gc.spread.sheets.print.14.2.2.min.js" type="text/javascript"></script>
    <script src="gc.spread.sheets.pdf.14.2.2.min.js" type="text/javascript"></script>
    <script src="gc.spread.sheets.charts.14.2.2.min.js" type="text/javascript"></script>
    <script src="v14.js" type="text/javascript"></script>
    <style type="text/css">
        #ss {
            height: 400px;
            width: 100%
        }
        p{
            color: #90156b;
            text-align: center;
        }
        #export{
            padding: 4px 16px;
            border: none;
            border-radius: 4px;
            background-color: #90156b;
            color: #fff;
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <p>导出筛选之前的页面</p>
    <input id="export" type="button" value="导出">
    <div id="ss"></div>
    <script type="text/javascript">
        GC.Spread.Common.CultureManager.culture('zh-cn');
        
        $(document).ready(function() {
            var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {
                sheetCount: 2
            });
            var excelIo = new GC.Spread.Excel.IO();
            var sheet = spread.getActiveSheet();
            sheet.setValue(1, 0, 1);
            sheet.setValue(2, 0, 2);
            sheet.setValue(3, 0, 3);
            sheet.setValue(4, 0, 4);
            sheet.setValue(5, 0, 5);
            sheet.setValue(6, 0, 6);
            sheet.setValue(7, 0, 7);
            var range = new GC.Spread.Sheets.Range(1, 0, 7, 1);
            var rowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(range);
            sheet.rowFilter(rowFilter);
            $("#export").click(function() {
                var tempSpread = new GC.Spread.Sheets.Workbook();
                tempSpread.fromJSON(spread.toJSON({
                    includeBindingSource: true,
                    columnHeadersAsFrozenRows: true
                }));
                for (var i = 0; i < tempSpread.getSheetCount(); i++) {
                    tempSheet = tempSpread.getSheet(i);
                    var rowFilter = tempSheet.rowFilter();
                    if (rowFilter != null) {
                        rowFilter.reset();
                    }
                }
                var json = tempSpread.toJSON();
                excelIo.save(json, function(blob) {
                    saveAs(blob, "export.xlsx");
                }, function(e) {
                    // process error
                    console.log(e);
                });
        
            });
        });
    </script>
</body>

</html>